ABC269 D - Do use hexagon grid
提出
code: python
n = int(input())
xy = sorted(xy, reverse=True, key=lambda x: x1) visited = []
def dfs(x_y):
visited.append(x_y)
to = -1, -1], -1, 0, 0, -1, 0, 1, 1, 0, [1, 1 for t in to:
if [x+t0, y+t1] not in xy: continue
if [x+t0, y+t1] in visited: continue
visited.append("#")
for x_y in xy:
if x_y in visited:
continue
dfs(x_y)
ans = 0
for i in range(len(visited)-1):
if visitedi != "#" and visitedi+1 == "#": ans += 1
print(ans)
解答
code: python
n = int(input())
offset = 1000
index_range = offset * 2 + 1
for x, y in xy:
def dfs(x, y):
for i in range(6):
if 0 <= x + to_xi and x + to_xi < index_range and \ 0 <= y + to_yi and y + to_yi < index_range and \ field[to_xi + x][to_yi + y] == 1: dfs(to_xi + x, to_yi + y) result = 0
for x in range(index_range):
for y in range(index_range):
dfs(x, y)
result += 1
print(result)
テーマ
メモ
提出
code: python
n = int(input())
visited = []
# 1000 * 1000
def dfs(nowx, nowy):
for t in range(6):
dfs(nextx, nexty)
print("yes")
for x in range(1000):
for y in range(1000):
dfs(x, y)
print("foo")